<link href="./css/style.css" rel="stylesheet" type="text/css" />
<div class="main">
<div class="cate">
	<p class="tt"><a>首页</a>><a href="goodslist.php">商品管理</a>><span>分类管理</span><a class='abtn2' style="float:right; width:auto; margin-right:10px;" href="catogry.php?act=add">添加分类</a></p>
	{if($msg==1)}
	<form class="cateadd">		
		<p class="p1"><span>分类名称</span><input type="text" name="t0" placeholder="请输入分类名称" /></p>
		<p class="p1"><span>导航显示</span><select name="t2"><option value='1'>是</option><option value='0'>否</option></select></p>
		<p class="p1"><span>产品类型</span><select name="t4"><option value='2'>{$catarr[2]}</option><option value='3'>{$catarr[3]}</option></select></p>
		<p class="p1"><span>栏目排序</span><input type="text" name="t3" placeholder="越大越靠前" /></p>
		<button type="button" class="tj" onclick="cateadd();">确认添加</button>
	</form>
	{elseif($msg==2)}
	<form class="catedit">
		<input type="hidden" value="{$info[Id]}" name="id" />		
		<p class="p1"><span>分类名称</span><input type="text" name="t0" placeholder="请输入分类名称" value="{$info[name]}" /></p>
		<p class="p1"><span>导航显示</span><select name="t2">
			<option value='0' {if($info['ismenu']==0)}selected{/if}>否</option>
			<option value='1' {if($info['ismenu']==1)}selected{/if}>是</option>
		</select></p>
		<p class="p1"><span>产品类型</span><label>{$catarr[$info[leixing]]}</label></p>
		<p class="p1"><span>栏目排序</span><input type="text" name="t3" placeholder="越大越靠前" value="{$info[px]}" /></p>
		<button type="button" class="tj" onclick="catedit();">确认修改</button>
	</form>
	{else}
	<div class='menu'>
			
			<div class='fl1'>
				<p class='bt1'>{$catarr[2]}</p>
				<table>				
					<tr class='li1'><th>名称</th><th>类型</th><th>导航</th><th>操作</th></tr>
					{loop $cat2 $key as $list}
					<tr >
						<td><a class="a" style='color:#666; text-decoration:none;' href="goodslist.php?cid={$list[Id]}">{$list[name]}</a></td>
						<td><span class="s1">{$catarr[$list[leixing]]}</span></td>
						<td><span class="s1">{$menu[$list[ismenu]]}</span></td>
						<td><span class="s4"><a class="a1 abtn2" style="float:none; width:auto;" href="catogry.php?id={$list[Id]}&act=add">编辑</a></span></td>
					</tr>
					{/loop}
				</table>
			</div>
			<div class='fl1'>
				<p class='bt1'>{$catarr[3]}</p>
				<table>				
					<tr class='li1'><th>名称</th><th>类型</th><th>导航</th><th>操作</th></tr>
					{loop $cat3 $key as $list}
					<tr >
						<td><a class="a" style='color:#666; text-decoration:none;' href="goodslist.php?cid={$list[Id]}">{$list[name]}</a></td>
						<td><span class="s1">{$catarr[$list[leixing]]}</span></td>
						<td><span class="s1">{$menu[$list[ismenu]]}</span></td>
						<td><span class="s4"><a class="a1 abtn2" style="float:none; width:auto;" href="catogry.php?id={$list[Id]}&act=add">编辑</a></span></td>
					</tr>
					{/loop}
				</table>
			</div>
		</div>
	{/if}
	<script src="./js/jquery.js"></script>
	<script>		
		function cateadd(){
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=cateadd",
					data:$(".cateadd").serialize(),
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='catogry.php';
						}
					}
				});
			}
			function catedit(){
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=g&a=cateedit",
					data:$(".catedit").serialize(),
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='catogry.php';
						}
					}
				});
			}
			
	</script>
	
</div>
</div>
<script>
	h1 = $(".main").height();
	h2 = $(".cate").height();
	if(h2>h1){
		$(".main").css("height","auto");
	}
	$('tr').click(function(){	
			$('tr').removeClass('onactive');
			$(this).addClass('onactive');
		});
</script>
